def checked(nums):
    return 2 <= nums <= 7


def findRight(func):
    left = 0
    right = int(1e10)
    ans = right
    while left <= right:
        mid = (left + right) // 2
        if func(mid):
            left = mid + 1
            ans = mid
        else:
            right = mid - 1
    if ans == int(1e10):
        return -1
    return ans


def findLeft(func, r):
    # 需要确保target~+inf 满足
    left = 0
    right = r
    ans = right
    while left <= right:
        mid = (left + right) // 2
        if func(mid):
            right = mid - 1
            ans = mid
        else:
            left = mid + 1
    if ans == int(1e10):
        return -1
    return ans


if __name__ == '__main__':
    right_ = findRight(checked)
    left_ = findLeft(checked, right_)
    print(left_, right_)
